//
//  PublicDefine.h
//  XDLBaseProject
//
//  Created by Xiedonglai on 17/1/10.
//  Copyright © 2017年 Apple. All rights reserved.
//

#ifndef PublicDefine_h
#define PublicDefine_h

//屏幕宽高
#define kScreenW ([UIScreen mainScreen].bounds.size.width)
#define kScreenH ([UIScreen mainScreen].bounds.size.height)

//狀態欄高度
#define kTatusBarH (iPhone_IPhoneX_All?44:20)
#define kNavigationBarH 44
#define kTopBarH (kTatusBarH + kNavigationBarH)
#define kTabBarH (iPhone_IPhoneX_All?49+34:49)

//一个像素的高度，通常用来计算分割线的的宽度
#define DIVIDING_LINE (1.00 / [UIScreen mainScreen].scale)

//self的弱引用
#define WeakSelf(weakSelf)  __weak typeof(self) weakSelf = self;

//设备型号
#define iPad_or_iPad_Mini ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(768, 1024), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPadRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(2048,1536), [[UIScreen mainScreen] currentMode].size) : NO)


#define iPhone12 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1170, 2532), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone12_min ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1080, 2340), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone12_proMax ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1284, 2778), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhoneXR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhoneXS_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhoneXS ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

//#define iPhone8 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6_Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6_Plus_amp ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2001), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)

#define iPhone_IPhoneX_All (iPhoneXS || iPhoneXS_Max || iPhoneXR || iPhone12_proMax || iPhone12_min || iPhone12)

//屏幕比例配适
//#define iphone5_scale_w 0.854
//#define iphone5_scale_h 0.852
#define iphone5_scale_w 0.854
#define iphone5_scale_h 0.815
#define iPhone6Plus_scale_w 1.104
#define iPhone6Plus_scale_h 1.1035

#define iPhoneXS_scale_w 1
//#define iPhoneXS_scale_h 1.217
#define iPhoneXS_scale_h 1.1
#define iPhoneXS_Max_scale_w 1.104
//#define iPhoneXS_Max_scale_h 1.343
#define iPhoneXS_Max_scale_h 1.22
//#define iPhoneXR_scale_w 0.736
//#define iPhoneXR_scale_h 0.896
#define iPhoneXR_scale_w 1.15
#define iPhoneXR_scale_h 1.23

#define SCREEN_WIDTH_BILI (kScreenW/375.0f)
#define X_Real(a) (a*SCREEN_WIDTH_BILI)
#define Width_Real(a) (a*SCREEN_WIDTH_BILI)

#define SCREEN_HEIGHT_BILI (kScreenH/812.0f)
#define Height_Real(a) (a*SCREEN_HEIGHT_BILI)
#define Y_Real(a) (a*SCREEN_HEIGHT_BILI)

#define rect_Real(x,y,w,h)  CGRectMake(x*SCREEN_WIDTH_BILI, y*SCREEN_HEIGHT_BILI, w*SCREEN_WIDTH_BILI, h*SCREEN_HEIGHT_BILI)


//#define APP_CGRectMake(x,y,w,h)  (iPhone5 || iPhone4)?CGRectMake((x)*iphone5_scale_w, (y)*iphone5_scale_h, (w)*iphone5_scale_w, (h)*iphone5_scale_h):iPhone6_Plus?CGRectMake((x)*iPhone6Plus_scale_w, (y)*iPhone6Plus_scale_h, (w)*iPhone6Plus_scale_w, (h)*iPhone6Plus_scale_h):iPhoneXS?CGRectMake((x)*iPhoneXS_scale_w, (y)*iPhoneXS_scale_h, (w)*iPhoneXS_scale_w, (h)*iPhoneXS_scale_h):iPhoneXS_Max?CGRectMake((x)*iPhoneXS_Max_scale_w, (y)*iPhoneXS_Max_scale_h, (w)*iPhoneXS_Max_scale_w, (h)*iPhoneXS_Max_scale_h):iPhoneXR?CGRectMake((x)*iPhoneXR_scale_w, (y)*iPhoneXR_scale_h, (w)*iPhoneXR_scale_w, (h)*iPhoneXR_scale_h):CGRectMake((x), (y), (w), (h))
//
//#define X_Real(a) (iPhone6?(a):(iPhone6_Plus)?((a)*iPhone6Plus_scale_w):(iPhone5 || iPhone4)?((a)*iphone5_scale_w):(iPhoneXS)?((a)*iPhoneXS_scale_w):(iPhoneXS_Max)?((a)*iPhoneXS_Max_scale_w):(iPhoneXR)?((a)*iPhoneXR_scale_w):(a))
//
//#define Y_Real(a) (iPhone6?(a):(iPhone6_Plus)?((a)*iPhone6Plus_scale_h):(iPhone5 || iPhone4)?((a)*iphone5_scale_h):(iPhoneXS)?((a)*iPhoneXS_scale_h):(iPhoneXS_Max)?((a)*iPhoneXS_Max_scale_h):(iPhoneXR)?((a)*iPhoneXR_scale_h):(a))
//
//#define Width_Real(a) (iPhone6?(a):(iPhone6_Plus)?((a)*iPhone6Plus_scale_w):(iPhone5 || iPhone4)?((a)*iphone5_scale_w):(iPhoneXS)?((a)*iPhoneXS_scale_w):(iPhoneXS_Max)?((a)*iPhoneXS_Max_scale_w):(iPhoneXR)?((a)*iPhoneXR_scale_w):(a))
//
//#define Height_Real(a) (iPhone6?(a):(iPhone6_Plus)?((a)*iPhone6Plus_scale_h):(iPhone5 || iPhone4)?((a)*iphone5_scale_h):(iPhoneXS)?((a)*iPhoneXS_scale_h):(iPhoneXS_Max)?((a)*iPhoneXS_Max_scale_h):(iPhoneXR)?((a)*iPhoneXR_scale_h):(a))

//字体全局配适
#define Font_real(a) [UIFont systemFontOfSize:(SCREEN_WIDTH_BILI * [[NSString stringWithFormat: @"%.1lf", (double)a] floatValue])]

//颜色的十六进值
#define UIColorFromHexA(hexValue, a)     [UIColor colorWithRed:(((hexValue & 0xFF0000) >> 16))/255.0f green:(((hexValue & 0xFF00) >> 8))/255.0f blue:((hexValue & 0xFF))/255.0f alpha:a]
#define UIColorFromHex(hexValue)        UIColorFromHexA(hexValue, 1.0f)

//定义随机色
#define randomColor     [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1]

//定義輸入限制
#define NUM @"0123456789"//只输入数字
#define ALPHA @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"//只输入字母
#define ALPHANUM @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"//数字和字母

//网络url
#define API_REGISTER            @"https://mynotecards.xyz:5122/test/registration"
#define API_LOGIN               @"https://mynotecards.xyz:5122/test/login"
#define API_GETUSERTYPE         @"https://mynotecards.xyz:5122/test/user_type"
#define API_UPLOADDATA          @"https://mynotecards.xyz:5122/test/upload"
#define API_DOWNLOADDATA        @"https://mynotecards.xyz:5122/test/download"
#define API_DOWNLOADJS          @"https://mynotecards.xyz:5122/test/downloadJS"

#endif /* PublicDefine_h */
